<?php

class OrderController extends Zend_Controller_Action
{

	/**
	 * 
	 * Enter description here ...
	 * @var Form_Order
	 */
	private $_form;
    public function init()
    {
        /* Initialize action controller here */
    	if(is_null($this->_form)){
    		$this->_form = new Form_Order();
    	}
    }

    public function sumAction()
    {
        // action body
        $this->_form->populate($this->_request->getPost());
        $ids = $this->_form->getElement("products")->getValue();
        
        foreach($ids as $key=>$value){
        	$this->_orders[] = new Model_Order($value, 
        		$this->_form->getElement("price_".$value)->getValue(), 
        		$this->_form->getElement("amount_".$value)->getValue());
        }
        $this->view->orders = $this->_orders;
        $this->view->orderName = $this->_form->getElement("orderName")->getValue();
        $this->view->address = $this->_form->getElement('address')->getValue();
        $this->view->cSticks = $this->_form->getElement('cSticks')->getValue();
    }


}

